package com.bai.qf2201.controller;

import com.bai.qf2201.po.User;
import com.bai.qf2201.service.Impl.userServiceImpl;
import com.bai.qf2201.service.userService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class userController {
    @Autowired
    private userService us;

    @ResponseBody
    @RequestMapping(value = "/Login",method = RequestMethod.POST)
    public User Login(String tel,String password){
        System.out.println(tel+"===="+password);

        User oneLogin = us.findOneLogin(tel,password);

        System.out.println(oneLogin);
        return oneLogin;
    }
    @ResponseBody
    @RequestMapping(value = "/AddUser",method = RequestMethod.POST)
    public int  AddUser(String tel,String password,String email,String invitation){
        System.out.println(tel+"===="+password+"=="+email+"=="+invitation);
            User user=new User();
            user.setTel(tel);
            user.setPassword(password);
            user.setEmail(email);
            user.setInvitation(invitation);
            int i = us.addOne(user);

            return 1;
    }

    @ResponseBody
    @RequestMapping(value = "/OneUser",method = RequestMethod.POST)
    public User findOneById (int id){
        System.out.println(id);
        User oneUser = us.findOneById(id);
        System.out.println(oneUser);
        return oneUser;
    }
    @ResponseBody
    @RequestMapping(value = "/updateTelById",method = RequestMethod.POST)
    public int  updateTelById (int id,String tel){
        System.out.println(id+"--"+tel);
        int i = us.updateTelById(id, tel);
        return i;
    }
}
